package cn.dankal.flyaudio.personal.driverlisense

import androidx.core.content.ContextCompat
import android.view.View
import android.view.ViewGroup
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewAdapter
import cn.dankal.basiclib.base.recyclerview.BaseRecyclerViewHolder
import cn.dankal.business.pojo.LisenseBean
import cn.dankal.flyaudio.R
import kotlinx.android.synthetic.main.rv_item_lisense.view.*


/**
 * 认证列表
 */
class LisenseAdapter : BaseRecyclerViewAdapter<LisenseBean>() {
    override fun getLayoutResId(viewType: Int): Int {
        return R.layout.rv_item_lisense
    }

    override fun getViewHolder(parent: ViewGroup?, rootView: View?, viewType: Int): BaseRecyclerViewHolder<LisenseBean> {
        return ViewHolder(rootView)
    }


    class ViewHolder(itemView: View?) : BaseRecyclerViewHolder<LisenseBean>(itemView) {
        override fun onBindData(data: LisenseBean, position: Int) {
            itemView.tv_name.text = data.name
            itemView.tv_mobile.text = data.phone
            when (data.auditStatus) {
                "1" -> {
                    val drawable = context.getResources().getDrawable(
                            R.mipmap.pic_mine_center_2)
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight())
                    itemView.tv_state.setCompoundDrawables(null, null, drawable, null)
                    itemView.tv_state.text = "审核通过"
                    itemView.tv_state.setTextColor(ContextCompat.getColor(context, R.color.color66))
                    itemView.tv_state.setBackgroundResource(R.drawable.rect_colorf6_20cor)
                }
                "2" -> {
                    val drawable = context.getResources().getDrawable(
                            R.mipmap.pic_mine_center_black)
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight())
                    itemView.tv_state.setCompoundDrawables(null, null, drawable, null)
                    itemView.tv_state.text = "审核拒绝"
                    itemView.tv_state.setTextColor(ContextCompat.getColor(context, R.color.colorFF))
                    itemView.tv_state.setBackgroundResource(R.drawable.rect_colo92_20cor)
                }
                else -> {
                    val drawable = context.getResources().getDrawable(
                            R.mipmap.pic_mine_center_2)
                    drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight())
                    itemView.tv_state.setCompoundDrawables(null, null, drawable, null)
                    itemView.tv_state.text = "审核中"
                    itemView.tv_state.setTextColor(ContextCompat.getColor(context, R.color.color66))
                    itemView.tv_state.setBackgroundResource(R.drawable.rect_colorf6_20cor)

                }
            }

        }
    }


}